#{extends 'main.html' /}
#{set title:post.title /}

<ul id="pagination">
    #{if post.previous()}
        <li id="previous">
            <a href="@{Application.show(post.previous().id)}">
                ${post.previous().title}
            </a>
        </li>
    #{/if}
    #{if post.next()}
        <li id="next">
            <a href="@{Application.show(post.next().id)}">
                ${post.next().title}
            </a>
        </li>
    #{/if}
</ul>

#{if flash.success}
    <p class="success">${flash.success}</p>
#{/if}

#{display post:post,as:'full'/}

<h3 id="comments">发表评论</h3>
 
#{form @Application.postComment(post.id)}
 
    #{ifErrors}
        <p class="error">
            #{errors}
            	${error}<br/>
            #{/errors}
        </p>
    #{/ifErrors}
 
    <p>
        <label for="author">名字 : </label>
        <input type="text" name="author" id="author" value="${params.author}" />
    </p>
    <p>
        <label for="url">博客 : </label>
        <input type="text" name="url" id="url" value="${params.url}" size="30"/>
    </p>
    <p>
        <label for="content">评论内容: </label>
        <textarea name="content" id="content">${params.content}</textarea>
    </p>
    <p>
    	<label for="code">请输入验证码: </label>
    	<img src="@{Application.captcha(randomID)}" />
    	<br />
    	<input type="text" name="code" id="code" size="18" value="" />
    	<input type="hidden" name="randomID" value="${randomID}" />
		</p>
    <p>
        <input type="submit" value="发表评论" />
    </p>
#{/form}

<script type="text/javascript" charset="utf-8">
    $(function() {         
        $('form').click(function() { 
            $('form').expose({api: true}).load(); 
        }); 
        
        if($('form .error').size()) {
            $('form').expose({api: true, loadSpeed: 0}).load(); 
            $('form input').get(0).focus();
        }
    });
</script>